#ifndef NETSERVER_H
#define NETSERVER_H

#define TCP_NODELAY     1

#include <pthread.h>
#include <vector>
#include <iostream>
#include <SDL/SDL_net.h>

#include "src/net/be_tcp_socket.h"

struct nClient
{
	nClient( unsigned int connecttime ) : 
		toclose(false),
		m_connecttime(connecttime)
	{};
	
	boost::shared_ptr<BeTcpSocket> clientsocket;
	bool toclose;
	unsigned int m_connecttime;
};


class Netserver
{
	public:
		Netserver(unsigned int port);
		~Netserver() {};
		
		boost::shared_ptr<nClient> getNewConnections(unsigned int connecttime);
		void checkIncomingMessages( boost::shared_ptr<nClient> n, std::vector<std::string>* messages );
		void sendMessage( boost::shared_ptr<nClient> n, std::string& msg );

	private:
		BeTcpSocket m_handle;
		char buffer[1024];
};

#endif
